<template>
  hello
  <el-input v-model = "msg"/>
  <el-button @click = "playMsg">播报消息</el-button>
</template>

<script>
import Speech from "speak-tts";
import {ref} from "vue";

export default {
  name: "Index",
  setup() {
    const speech = new Speech();
    const msg = ref("你好");
    speech.setLanguage("zh-CN");
    speech.init().then(() => {
      console.log("语音播报初始化完成");
    });
    return {
      speech,
      msg
    }
  },


  methods: {
    playMsg() {
      let _this = this;
      _this.speech.speak({text: _this.msg}).then(() => {

      });
    }
  }
}
</script>

<style scoped>

</style>